import QtQuick
import QtQuick3D
import QtQuick3D.Physics
import QtQuick3D.Helpers

import MineCraftUtils

//表示一个进行游戏的房间，房间外部有框架碰撞体

Node{
    id:root

    property bool active:true//该房间是否处于激活状态

    //房间的规模
    property vector3d extend:Qt.vector3d(16, 6, 16)

    //场景数据
    property alias sceneData:sceneData

    //场景构建器
    property alias builder:sceneData.builder

    //开始绘制场景数据
    signal buildScene

    MineCraftSceneData{
        id:sceneData
        onRebuild:{
            buildScene()
        }

        extend:root.extend
    }

    //由场景数据生成的场景多边形
    MineCraftSceneGeometry{
        id:sceneGeom
        scene:sceneData
    }

    //由场景多边形生成的场景碰撞体
    StaticRigidBody{
        id:sceneRigidBody
        collisionShapes: TriangleMeshShape{
            geometry: sceneGeom
        }
    }

    //由场景多边形生成的场景模型
    Model{
        id:scenModel
        pickable: true
        geometry: sceneGeom
        // materials:PrincipledMaterial{
        //         baseColor: "white"
        // }

        materials:         PrincipledMaterial{
            baseColorMap: Texture{
                mipFilter: Texture.Nearest
                magFilter: Texture.Nearest
                source: "./tex/blocks-RGBA.png"
            }
            alphaMode: PrincipledMaterial.Mask
            roughness: 1.0
        }
    }

    //房间的外边框
    Frame{
        extend:root.extend
    }
    
    Node {
        id: __materialLibrary__
    }
}

/*##^##
Designer {
    D{i:0;cameraSpeed3d:25;cameraSpeed3dMultiplier:1}
}
##^##*/
